package Maze;

import java.util.Arrays;
import java.util.Scanner;

//路径之谜
public class pash_Test {
    static int[] dx = {0, 1, 0, -1};
    static int[] dy = {1, 0, -1, 0};

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[][] map = new int[n + 1][n + 1];
        int[][] isFlag = new int[n + 1][n + 1];

        for (int j = 1; j <= n; j++) {
            int value = scanner.nextInt();
            map[0][j] = value;
            isFlag[0][j] = 1;
        }
        for (int j = 1; j <= n; j++) {
            int value = scanner.nextInt();
            map[j][0] = value;
            isFlag[j][0] = 1;
        }
        print(map);
        print(isFlag);
        node start = new node(1, 1);
        dfs(map, isFlag, start);
    }

    private static void dfs(int[][] map, int[][] isFlag, node start) {
        isFlag[start.getX()][start.getY()] = 1;

        for (int i = 0; i <= 3; i++) {
            int tx = start.getX() + dx[i];
            int ty = start.getY() + dy[i];
            boolean pd = pd(isFlag, map, tx, ty);
            if (pd) {

            }
        }

    }


    static boolean pd(int[][] map, int[][] isFlag, int tx, int ty) {
        if (isFlag[tx][ty] == 1)
            return false;
            //已被走过，不能再走，超出边界
        else if (tx < 1)
            return false;
            //从左侧走出方格
        else if (tx > map.length)
            return false;
            //从右侧走出方格
        else if (ty < 1)
            return false;
            //从上侧走出方格
        else if (ty > map[0].length)
            return false;
            //从下侧走出方格
        else if (map[tx][0] <= 0)
            return false;
            //没走到右下角，箭用完了
        else if (map[ty][0] <= 0)
            return false;
            //没走到右下角，箭用完了
        else return true;
    }

    static class node {
        int x;
        int y;

        public node(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int getX() {
            return x;
        }

        public int getY() {
            return y;
        }
    }

    private static void print(int[][] map) {
        System.out.println("====");
        for (int[] line : map) {
            System.out.println(Arrays.toString(line));
        }
        System.out.println("====");
    }
}
